<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>recursion | yangjunbo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
    <meta name="keywords" content="MinHow,MinHow's Blog" />
  
  <meta name="description" content="1.闭包概念:闭包就是可以读取其他函数内部变量的函数;由于在javascript中;只有函数内部的子函数才能读取局部变量;因此可以把闭包理解为:定义在一个函数内部的函数;而子函数访问到了外层函数的成员;则这个函数称之为一个闭包函数;闭包就是把函数内部和函数外部连接起来的一座桥梁;虽然这个函数拿到全局了;但是这个函数的作用域以定义是函数的作用域为准 ;函数嵌套一般才会用到 闭包函数123456789">
<meta property="og:type" content="article">
<meta property="og:title" content="recursion">
<meta property="og:url" content="http://yoursite.com/2016/05/07/recursion/index.html">
<meta property="og:site_name" content="yangjunbo">
<meta property="og:description" content="1.闭包概念:闭包就是可以读取其他函数内部变量的函数;由于在javascript中;只有函数内部的子函数才能读取局部变量;因此可以把闭包理解为:定义在一个函数内部的函数;而子函数访问到了外层函数的成员;则这个函数称之为一个闭包函数;闭包就是把函数内部和函数外部连接起来的一座桥梁;虽然这个函数拿到全局了;但是这个函数的作用域以定义是函数的作用域为准 ;函数嵌套一般才会用到 闭包函数123456789">
<meta property="og:updated_time" content="2017-08-28T14:28:08.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="recursion">
<meta name="twitter:description" content="1.闭包概念:闭包就是可以读取其他函数内部变量的函数;由于在javascript中;只有函数内部的子函数才能读取局部变量;因此可以把闭包理解为:定义在一个函数内部的函数;而子函数访问到了外层函数的成员;则这个函数称之为一个闭包函数;闭包就是把函数内部和函数外部连接起来的一座桥梁;虽然这个函数拿到全局了;但是这个函数的作用域以定义是函数的作用域为准 ;函数嵌套一般才会用到 闭包函数123456789">
  
  
    <link rel="icon" href="/favicon.ico">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="/css/style.css">
  <script src="/js/pace.min.js"></script>
  

  
  

</head>

<body>
  <div id="container">
      <header id="header">
    <div id="banner"></div>
    <div id="header-outer">
        <div id="header-row">
            <div id="logo">
                <a href="/">
                    <img src="/images/logo.png" alt="logo">
                </a>
            </div>
            <div class="header-info">
                <div id="header-title">
                    
                    <h2>
                        欢迎来到我的博客
                    </h2>
                    
                </div>
                <div id="header-description">
                    
                    <h3>
                        My name is yangjunbo
                    </h3>
                    
                </div>
            </div>
            <nav class="header-nav">
                <div class="social">
                    
                        <a title="Home"  href="http://yangjunboyjb.oschina.io/">
                            <i class="fa fa-home fa-2x"></i></a>
                    
                        <a title="Github" target="_blank" href="//github.com/wongminho">
                            <i class="fa fa-github fa-2x"></i></a>
                    
                        <a title="Weibo" target="_blank" href="http://weibo.com/5938689701/profile?topnav=1&wvr=6&is_all=1">
                            <i class="fa fa-weibo fa-2x"></i></a>
                    
                        <a   ">
                            <i class="fa fa-twitter fa-2x"></i></a>
                    
                </div>
            </nav>
        </div>
    </div>
</header>

      <div class="outer">
        <section id="main" class="body-wrap"><article id="post-recursion" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 class="post-title" itemprop="name">
      recursion
    </h1>
    <div class="post-title-bar">
      <ul>
          
        <li>
          <i class="fa fa-calendar"></i>  2016-05-07
        </li>
        <li>
          <i class="fa fa-eye"></i>
          <span id="busuanzi_value_page_pv"></span>
        </li>
      </ul>
    </div>
  

          
      </header>
    
    <div class="article-entry post-content" itemprop="articleBody">
      
            
            <h2 id="1-闭包"><a href="#1-闭包" class="headerlink" title="1.闭包"></a>1.闭包</h2><h3 id="概念"><a href="#概念" class="headerlink" title="概念:"></a>概念:</h3><p>闭包就是可以读取其他函数内部变量的函数;由于在javascript中;只有函数内部的子函数才能读取局部变量;因此可以把闭包理解为:定义在一个函数内部的函数;而子函数访问到了外层函数的成员;则这个函数称之为一个闭包函数;闭包就是把函数内部和函数外部连接起来的一座桥梁;虽然这个函数拿到全局了;但是这个函数的作用域以定义是函数的作用域为准 ;函数嵌套一般才会用到 闭包函数<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">fn</span>(<span class="params"></span>)</span>&#123;</div><div class="line">    <span class="keyword">var</span> foo = <span class="string">"bar"</span>;</div><div class="line">    <span class="function"><span class="keyword">function</span> <span class="title">inner</span>(<span class="params"></span>)</span>&#123;</div><div class="line">        <span class="built_in">console</span>.log(foo)</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">return</span> inner</div><div class="line">&#125;</div><div class="line"><span class="keyword">var</span> inner = fn();</div><div class="line">inner()</div></pre></td></tr></table></figure></p>
<p>函数对的作用域链和调用位置没有关系;函数的作用域和定义一时有关系;和调用时没关系 </p>

            <div class="post-copyright">
    <div class="content">
        <p>最后更新： 2017年08月28日 22:28</p>
        <p>原始链接： <a class="post-url" href="/2016/05/07/recursion/" title="recursion">http://yoursite.com/2016/05/07/recursion/</a></p>
        <footer>
            <a href="http://yoursite.com">
                <img src="/images/logo.png" alt="yangjunbo">
                yangjunbo
            </a>
        </footer>
    </div>
</div>

      
    </div>
    <footer class="article-footer">
        <ul class="article-footer-menu">
            
            
        </ul>
        
    </footer>
  </div>
</article>


    <aside class="post-toc-pos">
        <nav class="post-toc-wrap">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#1-闭包"><span class="post-toc-text">1.闭包</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#概念"><span class="post-toc-text">概念:</span></a></li></ol></li></ol>
        </nav>
    </aside>
    

<nav id="article-nav">
  
    <a href="/2016/06/05/ajax/" id="article-nav-newer" class="article-nav-link-wrap">

      <span class="article-nav-title">
        <i class="fa fa-hand-o-left" aria-hidden="true"></i>
        
          Ajax(detailed information)
        
      </span>
    </a>
  
  
    <a href="/2015/11/16/javascript (2)/" id="article-nav-older" class="article-nav-link-wrap">
      <span class="article-nav-title">javascriptObject</span>
      <i class="fa fa-hand-o-right" aria-hidden="true"></i>
    </a>
  
</nav>



    
</section>
        
      </div>
      <footer id="footer">
  <div class="outer">
    <div id="footer-info" class="inner">
      
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


      <p>
        Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
        Theme <a href="//github.com/wongminho/hexo-theme-miho" target="_blank">MiHo</a>
      &copy; 2017 yangjunbo<br>
      </p>
    </div>
  </div>
</footer>
    <script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script>
  var mihoConfig = {
      root: "http://yoursite.com",
      animate: true,
      isHome: false
  }
</script>
<div class="sidebar">
    <div id="sidebar-search">
        <i class="fa fa-search"></i>
    </div>
    <div class="sidebar-menu">
        <i class="fa fa-bars"></i>
    </div>
    <div id="sidebar-top">
        <span class="sidebar-top-icon"><i class="fa fa-angle-up"></i></span>
    </div>
</div>
<div class="sidebar-menu-box">
    <div class="sidebar-menu-box-container">
        <div id="sidebar-menu-box-tags">
            
        </div>
    </div>
    <a href="javascript:;" class="sidebar-menu-box-close">&times;</a>
</div>
<div class="search-wrap">
    <span class="search-close">&times;</span>
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
            <i class="icon icon-lg icon-chevron-left"></i>
        </a>
        <input class="search-field" placeholder="Search..." id="keywords">
        <a id="search-submit" href="javascript:;">
            <i class="fa fa-search"></i>
        </a>
</div>

<div class="search-container" id="search-container">
    <ul class="search-result" id="search-result">
    </ul>
</div>
<div id="search-tpl">
    <li class="search-result-item">
        <a href="{url}" class="search-item-li">
            <span class="search-item-li-title" title="{title}">{title}</span>
        </a>
    </li>
</div>
<script src="/js/search.js"></script>
<script src="/js/sidebar-menu-box.js"></script>


  <script src="//cdn.bootcss.com/particles.js/2.0.0/particles.min.js"></script>
  <div id="particles"></div>
  <script src="/js/particles.js"></script>







  <link rel="stylesheet" href="//cdn.bootcss.com/animate.css/3.5.0/animate.min.css">
  <script src="//cdn.bootcss.com/scrollReveal.js/3.0.5/scrollreveal.js"></script>
  <script src="/js/animate.js"></script>

  </div>
</body>
</html>